package polaczenie;

import java.sql.*;
import javax.naming.*;
import javax.sql.*;

public class GetConnection {

    Connection getSimpleConnection() {

        String DB_CONN_STRING = "jdbc:mysql://www.c0re.us:3306/test";
        String DRIVER_CLASS_NAME = "org.gjt.mm.mysql.Driver";
        String USER_NAME = "admin_balu";
        String PASSWORD = "123Balu";

        Connection result = null;
        try {
            Class.forName(DRIVER_CLASS_NAME).newInstance();
        } catch (Exception ex) {
            log("Check classpath. Cannot load db driver: " + DRIVER_CLASS_NAME);
        }

        try {
            result = DriverManager.getConnection(DB_CONN_STRING, USER_NAME, PASSWORD);
        } catch (SQLException e) {
            log("Driver loaded, but cannot connect to db: " + DB_CONN_STRING);
        }
        return result;
    }

    private static void log(Object aObject) {

        System.out.println(aObject);
    }

}
